package com.university.mentalhealthplatform.studentV3.repository;


import com.university.mentalhealthplatform.appModels.Student;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Repository
public interface StudentRepositoryV3 extends JpaRepository<Student, UUID> {

    // 根据用户名查找教师，并加载角色信息
    @EntityGraph(attributePaths = "roles")
    Optional<Student> findByUsername(String username);

    // 根据姓名查找教师，并加载角色信息
    @EntityGraph(attributePaths = "roles")
    List<Student> findByNameContaining(String name);

    // 获取所有教师，并加载角色信息
    @Override
    @EntityGraph(attributePaths = "roles")
    List<Student> findAll();

    List<Student> findByUsernameContaining(String keyword);
}
